// pages/moments/moments.js
const util = require("../../utils/util")
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getData()
  },
  //我的信息
  getdata(){
    let that = this;
    let _id = wx.getStorageSync('istokenid')
    wx.cloud.database().collection('chat_user').doc(
      _id
    ).get().then(res=>{
      console.log(res);
      that.setData({
        userInfoA:res.data
      })
    })
  },
  //发表
  userData(){
    wx.navigateTo({
      url: '/pages/moments/publish/publish',
    })
  },
  getData(){
    wx.cloud.database().collection('userList').orderBy('time','desc').get()
    .then(res=>{
      let list =res.data
      for(let i  in list) {
        list[i].time = util.formatTime(new Date(list[i].time))
      }
      this.setData({
        momentsData: list
      })
      console.log(res);})
  }
})